package com.learn.ioc.aware;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;

/**
 * SpringIOC 生命周期
 *
 * @author: ganquanzhong
 * @date: 2020/7/10 13:36
 */
public class AwareTest {

	public static void main(String[] args) {

		AnnotationConfigApplicationContext act = new AnnotationConfigApplicationContext(Hello.class);

		HelloAware helloAware = act.getBean("helloAware", HelloAware.class);

		helloAware.testAware();
	}
}
/* Output:
1. BeanNameAware's setBeanName >>>helloAware
2. BeanClassLoaderAware's setBeanClassLoader >>>sun.misc.Launcher$AppClassLoader@73d16e93
3. BeanFactoryAware's setBeanFactory >>>org.springframework.beans.factory.support.DefaultListableBeanFactory@d2cc05a: defining beans [org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,org.springframework.context.event.internalEventListenerProcessor,org.springframework.context.event.internalEventListenerFactory,hello,helloAware]; root of factory hierarchy
4. EnvironmentAware's setEnvironment >>>StandardEnvironment {activeProfiles=[], defaultProfiles=[default], propertySources=[PropertiesPropertySource {name='systemProperties'}, SystemEnvironmentPropertySource {name='systemEnvironment'}]}
5. EmbeddedValueResolverAware's setEmbeddedValueResolver >>>org.springframework.beans.factory.config.EmbeddedValueResolver@1f021e6c
6. ResourceLoaderAware's setResourceLoader (only applicable when running in an application context) >>>org.springframework.context.annotation.AnnotationConfigApplicationContext@65b3120a, started on Sat Oct 23 12:43:51 CST 2021
7. ApplicationEventPublisherAware's setApplicationEventPublisher (only applicable when running in an application context) >>>null
8. MessageSourceAware's setMessageSource (only applicable when running in an application context) >>>org.springframework.context.annotation.AnnotationConfigApplicationContext@65b3120a, started on Sat Oct 23 12:43:51 CST 2021
9. ApplicationContextAware's setApplicationContext (only applicable when running in an application context) >>>org.springframework.context.annotation.AnnotationConfigApplicationContext@65b3120a, started on Sat Oct 23 12:43:51 CST 2021
12.InitializingBean's afterPropertiesSet >>>自定义初始化方法，在init-method之前执行
10.BeanFactoryPostProcessor...postProcessBeanFactory...
	 initMethod >>>Generic bean: class [com.gqzdev.ioc.aware.HelloAware]; scope=singleton; abstract=false; lazyInit=false; autowireMode=0; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=null; initMethodName=initMethod; destroyMethodName=null; defined in file [F:\code\spring-framework-analysis\zhong-ioc\build\classes\java\main\com\gqzdev\ioc\aware\HelloAware.class]
	 当前BeanFactory中有7 个Bean [org.springframework.context.annotation.internalConfigurationAnnotationProcessor, org.springframework.context.annotation.internalAutowiredAnnotationProcessor, org.springframework.context.annotation.internalCommonAnnotationProcessor, org.springframework.context.event.internalEventListenerProcessor, org.springframework.context.event.internalEventListenerFactory, hello, helloAware]
11.postProcessBeforeInitialization methods of BeanPostProcessors >>>hello=>com.gqzdev.ioc.aware.Hello$$EnhancerBySpringCGLIB$$8dab3277@de3a06f
14.postProcessAfterInitialization methods of BeanPostProcessors >>>hello=>com.gqzdev.ioc.aware.Hello$$EnhancerBySpringCGLIB$$8dab3277@de3a06f
gqzdev hello world!
*///~